package com.lyn.pluginapi.api

import android.content.Intent
import android.content.res.Resources
import android.graphics.drawable.Drawable
import android.os.Bundle
import android.view.KeyEvent
import android.view.LayoutInflater
import android.view.Menu
import android.view.MenuItem
import android.view.MotionEvent
import android.view.View
import android.widget.Toast
import androidx.activity.result.ActivityResult
import androidx.annotation.DrawableRes
import androidx.annotation.LayoutRes
import androidx.annotation.StringRes
import androidx.appcompat.app.AppCompatActivity
import androidx.lifecycle.Lifecycle
import androidx.lifecycle.LifecycleCoroutineScope

/**
 * 插件生命周期
 * @author longyn 2025/07/04
 * @version 1.0.0
 */
interface PluginApi {

    fun onProxyActivity(pluginId: String, activity: AppCompatActivity)

    fun onCreate(savedInstanceState: Bundle?)

    fun onStart()

    fun onResume()

    fun onPause()

    fun onStop()

    fun onDestroy()

    fun getResources(): Resources

    fun getClassLoader(): ClassLoader

    fun getString(@StringRes resId: Int): String

    fun getDrawable(@DrawableRes resId: Int): Drawable?

    fun getLayoutInflater(): LayoutInflater

    fun setContentView(@LayoutRes layoutResID: Int)

    fun setContentView(view: View)

    fun dispatchTouchEvent(ev: MotionEvent?): Boolean

    fun dispatchKeyEvent(event: KeyEvent?): Boolean

    fun onKeyDown(keyCode: Int, event: KeyEvent?): Boolean

    fun onKeyLongPress(keyCode: Int, event: KeyEvent?): Boolean

    fun onKeyUp(keyCode: Int, event: KeyEvent?): Boolean

    /**
     * 是否启用返回自己处理
     */
    fun isHandleOnBackPressedEnabled():Boolean

    /**
     * 处理返回事件
     */
    fun onHandleOnBackPressed()


    fun showToast(message:String,duration:Int = Toast.LENGTH_SHORT)

    /**
     * activity 返回结果
     */
    fun onActivityResultCallback(activityResult: ActivityResult)

    /**
     * 启动activity
     */
    fun starActivity(clazz:Class<*>)

    /**
     * 销毁
     */
    fun finish()

    fun getLifecycle():Lifecycle

    fun getLifecycleScope(): LifecycleCoroutineScope

    fun onOptionsItemSelected(item: MenuItem): Boolean

    fun onCreateOptionsMenu(menu: Menu?): Boolean

    fun getIntent():Intent

    fun onNewIntent(intent: Intent?)

}